<?php

class Processo extends DataMapper {

	var $error_prefix = '<div class="alert alert-danger" role="alert">';
    var $error_suffix = '</div>';
	
    var $table = 'processos';
	
	var $has_one = array("tipoprocesso","assunto");
	
	var $has_many = array("parte","usuario", "parte_processo", "anexo_processo", "apenso","processo_usuario","assentamento");
	
	
	var $validation = array(
		'dt_processo' => array(
			'label' => 'Data Processo',
			'rules' => array('required')
		),
		'tipoprocesso_id' => array(
			'label' => 'Tipo Processo',
			'rules' => array('required')
		),
		'numeroprocesso' => array(
			'label' => 'Processo Número',
			'rules' => array('required')
		)
	);

    function __construct($id = NULL){
        parent::__construct($id);
    }
	//public function sorteioUsuario($param, $excecao = 0, $exceto = NULL)   {
	public function sorteioUsuario($param, $excecao = 0)   {
		$retorno = '';
		
		if($excecao == '0'){
			$result = $this->db->query("
				SELECT usuarios.nome_completo,`usuarios`.`id`, (SELECT COUNT(*) AS tipoprocesso
				FROM `processos`
				WHERE `processos`.`tipoprocesso_id` = '".$param."'
				AND `processos`.`usuario_id` = usuarios.id AND date(processos.dt_cadastro) >= '2014-11-17' AND processos.status = '1') AS qtd
				FROM (`processos`)
				RIGHT OUTER JOIN `usuarios` usuarios ON `usuarios`.`id` = `processos`.`usuario_id`
				WHERE `usuarios`.`status` =  '1' and usuarios.permissao_id = '3'  AND usuarios.excecao = '0'
				GROUP BY `usuarios`.`id`
				ORDER BY `qtd` asc, `nome_completo` asc 
				LIMIT 1		
			");	
		}else{
			$result = $this->db->query("
				SELECT usuarios.nome_completo,`usuarios`.`id`, (SELECT COUNT(*) AS tipoprocesso
				FROM `processos`
				WHERE `processos`.`tipoprocesso_id` = '".$param."'
				AND `processos`.`usuario_id` = usuarios.id AND date(processos.dt_cadastro) >= '2014-11-17' AND processos.status = '1') AS qtd
				FROM (`processos`)
				RIGHT OUTER JOIN `usuarios` usuarios ON `usuarios`.`id` = `processos`.`usuario_id`
				WHERE `usuarios`.`status` =  '1' and usuarios.permissao_id = '3'  AND usuarios.excecao = '".$excecao."'  
				GROUP BY `usuarios`.`id` AND usuarios.excecao = '$excecao'  
				ORDER BY `qtd` asc, `nome_completo` asc 
				LIMIT 1		
			");	
		
		}
		
		/*
		ANALISAR COM MAIS CALMA FUTURAMENTE
		$result = $this->db->query("
		SELECT atende.login,`atende`.`id`, (
		SELECT COUNT(*) AS tipoprocesso
		FROM `processos`
		WHERE `processos`.`tipoprocesso_id` = '1' AND `processos`.`usuario_id` = atende.id) AS qtd
		FROM (`processos`)
		RIGHT OUTER
		JOIN (
		SELECT usuarios.login, usuarios.id, usuarios.status
		FROM tipoprocessos_usuarios
		LEFT JOIN `usuarios` usuarios ON `usuarios`.`id` = `tipoprocessos_usuarios`.`usuario_id`
		WHERE tipoprocesso_id='1'

		) AS atende ON `atende`.`id` = `processos`.`usuario_id`
		WHERE `atende`.`status` = '1'
		GROUP BY `atende`.`id`
		ORDER BY `qtd` ASC, `login` ASC;
		");*/
				
        $this->_process_query($result);
		
        foreach($this as $dado){
			$retorno = $dado->id;
		}
		return $retorno;
    }
	public function sorteioUsuarioRedist($param, $exceto = 0, $excecao = 0){
		$retorno = '';
		$string = '';
		if($exceto != NULL){
			$exceto = implode(",", $exceto);
			$string = ' AND usuarios.id NOT IN ('.$exceto.') ';
		}
		
		if($excecao == '0'){
			$result = $this->db->query("
				SELECT usuarios.nome_completo,`usuarios`.`id`, (SELECT COUNT(*) AS tipoprocesso
				FROM `processos`
				WHERE `processos`.`tipoprocesso_id` = '".$param."'
				AND `processos`.`usuario_id_redist` = usuarios.id AND date(processos.dt_cadastro) >= '2014-11-17' AND processos.status = '1') AS qtd
				FROM (`processos`)
				right OUTER JOIN `usuarios` usuarios ON `usuarios`.`id` = `processos`.`usuario_id`
				WHERE `usuarios`.`status` =  '1' and usuarios.permissao_id = '3' ".$string."  AND usuarios.excecao = '0'
				GROUP BY `usuarios`.`id`
				ORDER BY `qtd` asc, `nome_completo` asc 
				LIMIT 1
			");			
		}else{
			$result = $this->db->query("
				SELECT usuarios.nome_completo,`usuarios`.`id`, (SELECT COUNT(*) AS tipoprocesso
				FROM `processos`
				WHERE `processos`.`tipoprocesso_id` = '".$param."'
				AND `processos`.`usuario_id_redist` = usuarios.id AND date(processos.dt_cadastro) >= '2014-11-17' AND processos.status = '1') AS qtd
				FROM (`processos`)
				right OUTER JOIN `usuarios` usuarios ON `usuarios`.`id` = `processos`.`usuario_id`
				WHERE `usuarios`.`status` =  '1' and usuarios.permissao_id = '3' ".$string."  AND usuarios.excecao = '".$excecao."' 
				GROUP BY `usuarios`.`id`
				ORDER BY `qtd` asc, `nome_completo` asc 
				LIMIT 1
			");
		
		}
		
        $this->_process_query($result);
		
        foreach($this as $dado){
			$retorno = $dado->id;
		}
		return $retorno;
    }
	public function sorteioUsuarioManual($tipoprocesso, $excecao){
	

		$excecao = implode(",", $excecao);
		$string = " AND usuarios.id NOT IN ('8','".$excecao."') ";


		$result = $this->db->query("
			SELECT usuarios.nome_completo,`usuarios`.`id`, (SELECT COUNT(*) AS tipoprocesso
			FROM `processos`
			WHERE `processos`.`tipoprocesso_id` = '".$tipoprocesso."'
			AND `processos`.`usuario_id` = usuarios.id AND date(processos.dt_cadastro) >= '2014-11-17' AND processos.status = '1') AS qtd
			FROM (`processos`)
			right OUTER JOIN `usuarios` usuarios ON `usuarios`.`id` = `processos`.`usuario_id`
			WHERE `usuarios`.`status` =  '1' and usuarios.permissao_id = '3' ".$string ." 
			GROUP BY `usuarios`.`id`
			ORDER BY `qtd` asc, `nome_completo` asc 
			LIMIT 1
		");			
		
        $this->_process_query($result);
		
        foreach($this as $dado){
			$retorno = $dado->id;
		}
		return $retorno;
    }
	public function listaProcessos($busca = null, $status = null){
		
		if(!empty($busca)){
			$string = "
			WHERE 
			processos.numeroprocesso like '%".$busca."%' 
			OR usuarios.nome_completo like '%".$busca."%'
			OR tipoprocessos.nomeprocesso like '%".$busca."%'
			";
			
		}else{
			$string = '';
			
		}
		
		if(!empty($status)){
			$status = " AND processos.status='".$status."' ";
		}else{
			$status = '';
		}
		
        $result = $this->db->query("
		SELECT processos.dt_cadastro, processos.id, processos.numeroprocesso, processos.dt_processo, processos.usuario_id, processos.usuario_id_assis,processos.usuario_id_redist, processos.status,tipoprocessos.nomeprocesso, usuarios.nome_completo
		FROM processos
		LEFT OUTER
		JOIN tipoprocessos ON tipoprocessos.id = processos.tipoprocesso_id
		LEFT OUTER
		JOIN usuarios ON usuarios.id = processos.usuario_id ".
		$string.$status." 
		ORDER BY dt_processo DESC	
		");
		
		$processo = new Processo();
		$processo->_process_query($result);
		
		return $processo;


    }
	public function pluck ( $a, $prop )	{
		$out = array();

		for ( $i=0, $len=count($a) ; $i<$len ; $i++ ) {
			$out[] = $a[$i][$prop];
		}

		return $out;
	}
	public function consultaProcessosJson(){
	
		$table = "processos";
		$columns = array(
		
			array( 'db' => 'processos.numeroprocesso','dt' => 0 ),
			array( 'db' => 'date_format(processos.dt_processo, "%d/%m/%Y") as dt_processo','dt' => 1 ),
			array( 'db' => 'tipoprocessos.nomeprocesso','dt' => 2 ),
			array( 'db' => 'usuarios.nome_completo','dt' => 3 ),
			array( 'db' => 'processos.cd_bic','dt' => 4 ),
			array( 'db' => 'processos.observacao','dt' => 5 ),
			array( 'db' => 'processos.status','dt' => 6 ),
			array( 'db' => 'processos.mov','dt' => 7 ),
			array( 'db' => 'processos.usuario_id','dt' => 8 ),
			array( 'db' => 'processos.usuario_id_assis','dt' => 9 ),
			array( 'db' => 'processos.usuario_id_redist','dt' => 10 ),
			array( 'db' => 'processos.id','dt' => 11 )
		);
		
		$columnsaux = array(
		
			array( 'db' => 'processos.numeroprocesso','dt' => 0 ),
			array( 'db' => 'processos.dt_processo','dt' => 1 ),
			array( 'db' => 'tipoprocessos.nomeprocesso','dt' => 2 ),
			array( 'db' => 'usuarios.nome_completo','dt' => 3 ),
			array( 'db' => 'processos.cd_bic','dt' => 4 ),
			array( 'db' => 'processos.observacao','dt' => 5 ),
			array( 'db' => 'processos.status','dt' => 6 ),
			array( 'db' => 'processos.mov','dt' => 7 ),
			array( 'db' => 'processos.usuario_id','dt' => 8 ),
			array( 'db' => 'processos.usuario_id_assis','dt' => 9 ),
			array( 'db' => 'processos.usuario_id_redist','dt' => 10 ),
			array( 'db' => 'processos.id','dt' => 11 )
			
		);
		//**********************************************************************
		// LIMITE
		//**********************************************************************
		$sLimit = "";
		if ( isset( $_GET['start'] ) && $_GET['length'] != '-1' )
		{
			$sLimit = "LIMIT ".intval( $_GET['start'] ).", ".intval( $_GET['length'] );
		}
		
		
		//**********************************************************************
		// ORDENAÇÃO
		//**********************************************************************
		$order = '';
	
		if ( isset($_GET['order']) && count($_GET['order']) ) {
			$orderBy = array();
			$dtColumns = $this->pluck( $columnsaux, 'dt' );

			for ( $i=0, $ien=count($_GET['order']) ; $i<$ien ; $i++ ) {
				// Convert the column index into the column data property
				$columnIdx = intval($_GET['order'][$i]['column']);
				$requestColumn = $_GET['columns'][$columnIdx];

				$columnIdx = array_search( $requestColumn['data'], $dtColumns );
				$column = $columnsaux[ $columnIdx ];

				if ( $requestColumn['orderable'] == 'true' ) {
					$dir = $_GET['order'][$i]['dir'] === 'asc' ?
						'ASC' :
						'DESC';

					$orderBy[] = ''.$column['db'].' '.$dir;
				}
			}

			$order = 'ORDER BY '.implode(', ', $orderBy);
		}
		
		$globalSearch = array();
		$columnSearch = array();
		$dtColumns = $this->pluck( $columnsaux, 'dt' );

		if(isset($_GET["busca"]) && $_GET["busca"] !== '' ){
			
			$str = $_GET["busca"];

			for ( $i=0, $ien=count($_GET['columns']) ; $i<$ien ; $i++ ) {
				$requestColumn = $_GET['columns'][$i];
				$columnIdx = array_search( $requestColumn['data'], $dtColumns );
				$column = $columnsaux[ $columnIdx ];

				if ( $requestColumn['searchable'] == 'true' ) {
					//$binding = '%'.$str.'%';
					if($column['db'] == 'processos.dt_processo'){$globalSearch[] = " ".$column['db']." LIKE '%".brToUsa($str)."%'";	}else{
						$globalSearch[] = " ".$column['db']." LIKE '%".$str."%'";
					}
				}
			}
			
		}else{
			if ( isset($_GET['search']) && $_GET['search']['value'] != '' ) {
				$str = $_GET['search']['value'];

				for ( $i=0, $ien=count($_GET['columns']) ; $i<$ien ; $i++ ) {
					$requestColumn = $_GET['columns'][$i];
					$columnIdx = array_search( $requestColumn['data'], $dtColumns );
					$column = $columnsaux[ $columnIdx ];

					if ( $requestColumn['searchable'] == 'true' ) {
						//$binding = '%'.$str.'%';
						if($column['db'] == 'processos.dt_processo'){$globalSearch[] = " ".$column['db']." LIKE '%".brToUsa($str)."%'";}else{
							$globalSearch[] = " ".$column['db']." LIKE '%".$str."%'";
						}
					}
				}
			}

		}
		$status = '';
		
		//**********************************************************************
		// WHERE
		//**********************************************************************
		// Individual column filtering
		for ( $i=0, $ien=count($_GET['columns']) ; $i<$ien ; $i++ ) {
			$requestColumn = $_GET['columns'][$i];
			$columnIdx = array_search( $requestColumn['data'], $dtColumns );
			$column = $columnsaux[ $columnIdx ];

			$str = $requestColumn['search']['value'];

			if ( $requestColumn['searchable'] == 'true' && $str != '' ) {
				//$binding = '%'.$str.'%';
				$columnSearch[] = " ".$column['db']." LIKE '%".$str."%'";
			}
		}

		// Combine the filters into a single string
		$where = '';

		if ( count( $globalSearch ) ) {
			$where = '('.implode(' OR ', $globalSearch).')';
			if(isset($_GET["status"]) && $_GET["status"] != ''){
				$status = " processos.status='".$_GET["status"]."'";
				$where .= " AND ".$status;
			}
		}

		if ( count( $columnSearch ) ) {
			$where = $where === '' ? 
				implode(' AND ', $columnSearch) :
				$where .' AND '. implode(' AND ', $columnSearch);
		}

		
		if ( $where !== '' ) {
			$where = 'WHERE '.$where;
		}else{
			if(isset($_GET["status"]) && $_GET["status"] != ''){
				if ($_GET["status"] == '2'){ $valor = '0';}else{ $valor = '1';}
				$status = " processos.status='".$valor."'";
				$where = 'WHERE '.$status;
			}			
		}
		
		//$where .= $status;
		
        $result = $this->db->query("
		SELECT 
		".implode(", ", $this->pluck($columns, 'db'))." 
		FROM $table 
		LEFT OUTER 
		JOIN tipoprocessos ON tipoprocessos.id = processos.tipoprocesso_id 
		LEFT OUTER  
		JOIN usuarios ON usuarios.id = processos.usuario_id  
		$where
		$order  
		$sLimit	 
		");
	/*
		echo "
		SELECT 
		".implode(", ", $this->pluck($columns, 'db'))." 
		FROM $table 
		LEFT OUTER 
		JOIN tipoprocessos ON tipoprocessos.id = processos.tipoprocesso_id 
		LEFT OUTER  
		JOIN usuarios ON usuarios.id = processos.usuario_id  
		$where
		$order  
		$sLimit	 ";
	*/
		
		$processo = new Processo();
		$processo->_process_query($result);
		
		$result = $this->db->query("SELECT FOUND_ROWS() as recordsTotal");
		$p1 = new Processo();
		$p1->_process_query($result);
		$recordsTotal = '';
		foreach($p1 as $u){
			$recordsTotal = $p1->recordsTotal;
		}
		
		
		$result = $this->db->query("SELECT COUNT(processos.id) as recordsFiltered  FROM processos");
		$p2 = new Processo();
		$recordsFiltered = '';
		$p2->_process_query($result);
		foreach($p2 as $u){
			$recordsFiltered = $p2->recordsFiltered;
		}
		
		$dados = array();
		$vetor = array();
		$vetor["draws"] = $_GET['draw'];
		$vetor["recordsTotal"] = $recordsTotal;
		$vetor["recordsFiltered"] = $recordsFiltered;
		foreach($processo as $u){
			$aux = array();
			

			$aux[] = $u->numeroprocesso;
			$aux[] = $u->dt_processo;
			$aux[] = $u->nomeprocesso;
			
			
			if($u->usuario_id != NULL){ 
				$red = new Usuario();
				$aux[] = $red->nomeUsuario($u->usuario_id);
			}else{
				$aux[] = null;
			}
			
			$aux[] = $u->cd_bic;
			$aux[] = $u->observacao;          
			$info = '';
			
			
			if($u->usuario_id_redist != NULL){ 
				$red = new Usuario();
				$info = '<img style="padding-right:5px;" src="'.base_url('includes/images/adv.png').'" title="'.$red->nomeUsuario($u->usuario_id_redist).'" >';
			}
			$assistente = '';
			
			if($u->usuario_id_assis != NULL){ 
				$red = new Usuario();
				$info .= '<img style="padding-right:5px;" src="'.base_url('includes/images/ass.png').'" title="'.$red->nomeUsuario($u->usuario_id_assis).'">';
			}else{
				$assistente = '<a style="padding-left:5px;" data-toggle="modal"  data-target="#addassis" href="'.base_url("index.php/processos/assistente/$u->id").'" class="btn btn-primary btn-xs"><span class="glyphicon glyphicon-hand-right"></span> Assistente</a>';
			}
			
			if($u->status == '0'){ 
				$info .= '<img src="'.base_url('includes/images/arquivado.png').'" title="PROCESSO ARQUIVADO">';
			}
			
			if($u->mov == 'S'){ 
				$info .= '<img src="'.base_url('includes/images/saida1.png').'" title="PROCESSO FORA PROJU">';
			}
			
			$aux[] = $info;	
                       
            		
			$aux[] = '<a style="padding: 1px 1px 1px 1px;" href="'.base_url("index.php/processos/info/$u->id").'" class="btn btn-success btn-xs"><span class="glyphicon glyphicon-plus"></span>Detalhes</a> '.$assistente.' <a style="padding: 1px 1px 1px 1px;" target=_blank href="'.base_url("index.php/processos/acompanhamento/$u->id").'" class="btn btn-info btn-xs"><span class="glyphicon glyphicon-print"></span> Imprimir</a>';
			
			
			array_push($dados,$aux);
		}
		$vetor["data"] = $dados;
		
		
		echo json_encode($vetor);
    }
	public function consultaMeusProcessosJson($id = null){
		$usuario_id = NULL;
		if($id != null || !empty($id)){
			$usuario_id =  " usuario_id = '".$id."'";
		}
		
	
		$table = "processos";
		$columns = array(
		
			array( 'db' => 'processos.numeroprocesso','dt' => 0 ),
			array( 'db' => 'date_format(processos.dt_processo, "%d/%m/%Y") as dt_processo','dt' => 1 ),
			array( 'db' => 'tipoprocessos.nomeprocesso','dt' => 2 ),
			array( 'db' => 'usuarios.nome_completo','dt' => 3 ),
			array( 'db' => 'processos.usuario_id','dt' => 4 ),
			array( 'db' => 'processos.usuario_id_assis','dt' => 5 ),
			array( 'db' => 'processos.usuario_id_redist','dt' => 6 ),
			array( 'db' => 'processos.status','dt' => 7 ),
			array( 'db' => 'processos.mov','dt' => 8 ),
			array( 'db' => 'processos.id','dt' => 9 )
		);
		
		$columnsaux = array(
		
			array( 'db' => 'processos.numeroprocesso','dt' => 0 ),
			array( 'db' => 'processos.dt_processo','dt' => 1 ),
			array( 'db' => 'tipoprocessos.nomeprocesso','dt' => 2 ),
			array( 'db' => 'usuarios.nome_completo','dt' => 3 ),
			array( 'db' => 'processos.usuario_id','dt' => 4 ),
			array( 'db' => 'processos.usuario_id_assis','dt' => 5 ),
			array( 'db' => 'processos.usuario_id_redist','dt' => 6 ),
			array( 'db' => 'processos.status','dt' => 7 ),
			array( 'db' => 'processos.mov','dt' => 8 ),
			array( 'db' => 'processos.id','dt' => 9 )
		);
		//**********************************************************************
		// LIMITE
		//**********************************************************************
		$sLimit = "";
		if ( isset( $_GET['start'] ) && $_GET['length'] != '-1' )
		{
			$sLimit = "LIMIT ".intval( $_GET['start'] ).", ".intval( $_GET['length'] );
		}
		
		
		//**********************************************************************
		// ORDENAÇÃO
		//**********************************************************************
		$order = '';
	
		if ( isset($_GET['order']) && count($_GET['order']) ) {
			$orderBy = array();
			$dtColumns = $this->pluck( $columnsaux, 'dt' );

			for ( $i=0, $ien=count($_GET['order']) ; $i<$ien ; $i++ ) {
				// Convert the column index into the column data property
				$columnIdx = intval($_GET['order'][$i]['column']);
				$requestColumn = $_GET['columns'][$columnIdx];

				$columnIdx = array_search( $requestColumn['data'], $dtColumns );
				$column = $columnsaux[ $columnIdx ];

				if ( $requestColumn['orderable'] == 'true' ) {
					$dir = $_GET['order'][$i]['dir'] === 'asc' ?
						'ASC' :
						'DESC';

					$orderBy[] = ''.$column['db'].' '.$dir;
				}
			}

			$order = 'ORDER BY '.implode(', ', $orderBy);
		}
		
		$globalSearch = array();
		$columnSearch = array();
		$dtColumns = $this->pluck( $columnsaux, 'dt' );

		if(isset($_GET["busca"]) && $_GET["busca"] !== '' ){
			
			$str = $_GET["busca"];

			for ( $i=0, $ien=count($_GET['columns']) ; $i<$ien ; $i++ ) {
				$requestColumn = $_GET['columns'][$i];
				$columnIdx = array_search( $requestColumn['data'], $dtColumns );
				$column = $columnsaux[ $columnIdx ];

				if ( $requestColumn['searchable'] == 'true' ) {
					//$binding = '%'.$str.'%';
					$globalSearch[] = " ".$column['db']." LIKE '%".$str."%'";
				}
			}
			
		}else{
			if ( isset($_GET['search']) && $_GET['search']['value'] != '' ) {
				$str = $_GET['search']['value'];

				for ( $i=0, $ien=count($_GET['columns']) ; $i<$ien ; $i++ ) {
					$requestColumn = $_GET['columns'][$i];
					$columnIdx = array_search( $requestColumn['data'], $dtColumns );
					$column = $columnsaux[ $columnIdx ];

					if ( $requestColumn['searchable'] == 'true' ) {
						//$binding = '%'.$str.'%';
						$globalSearch[] = " ".$column['db']." LIKE '%".$str."%'";
					}
				}
			}

		}
		$status = '';
		
		//**********************************************************************
		// WHERE
		//**********************************************************************
		// Individual column filtering
		for ( $i=0, $ien=count($_GET['columns']) ; $i<$ien ; $i++ ) {
			$requestColumn = $_GET['columns'][$i];
			$columnIdx = array_search( $requestColumn['data'], $dtColumns );
			$column = $columnsaux[ $columnIdx ];

			$str = $requestColumn['search']['value'];

			if ( $requestColumn['searchable'] == 'true' &&
			 $str != '' ) {
				//$binding = '%'.$str.'%';
				$columnSearch[] = " ".$column['db']." LIKE '%".$str."%'";
			}
		}

		// Combine the filters into a single string
		$where = '';

		if ( count( $globalSearch ) ) {
			$where = '('.implode(' OR ', $globalSearch).')';
			if(isset($_GET["status"]) && $_GET["status"] != ''){
				$status = " processos.status='".$_GET["status"]."' AND $usuario_id";
				$where .= " AND ".$status;
			}
		}

		if ( count( $columnSearch ) ) {
			$where = $where === '' ? 
				implode(' AND ', $columnSearch) :
				$where .' AND '. implode(' AND ', $columnSearch);
		}

		
		if ( $where !== '' ) {
			$where = 'WHERE '.$where;
		}else{
			if(isset($_GET["status"]) && $_GET["status"] != ''){
				if ($_GET["status"] == '2'){ $valor = '0';}else{ $valor = '1';}
				$status = " processos.status='".$valor."' AND $usuario_id";
				$where = 'WHERE '.$status;
			}elseif($usuario_id != null){
				$where = 'WHERE '.$usuario_id;
			
			}
			
		}
		
		//$where .= $status;
		
        $result = $this->db->query("
		SELECT 
		".implode(", ", $this->pluck($columns, 'db'))." 
		FROM $table 
		LEFT OUTER 
		JOIN tipoprocessos ON tipoprocessos.id = processos.tipoprocesso_id 
		LEFT OUTER  
		JOIN usuarios ON usuarios.id = processos.usuario_id  
		$where
		$order  
		$sLimit	 
		");
		/*
		echo "
		SELECT 
		".implode(", ", $this->pluck($columns, 'db'))." 
		FROM $table 
		LEFT OUTER 
		JOIN tipoprocessos ON tipoprocessos.id = processos.tipoprocesso_id 
		LEFT OUTER  
		JOIN usuarios ON usuarios.id = processos.usuario_id  
		$where
		$order  
		$sLimit	 ";*/
		
		$processo = new Processo();
		$processo->_process_query($result);
		
		$result = $this->db->query("SELECT FOUND_ROWS() as recordsTotal from processos  WHERE $usuario_id");
		$p1 = new Processo();
		$p1->_process_query($result);
		$recordsTotal = '';
		foreach($p1 as $u){
			$recordsTotal = $p1->recordsTotal;
		}
		
		
		$result = $this->db->query("SELECT COUNT(processos.id) as recordsFiltered  FROM processos WHERE $usuario_id");
		$p2 = new Processo();
		$recordsFiltered = '';
		$p2->_process_query($result);
		foreach($p2 as $u){
			$recordsFiltered = $p2->recordsFiltered;
		}
		
		$dados = array();
		$vetor = array();
		$vetor["draws"] = $_GET['draw'];
		$vetor["recordsTotal"] = $recordsTotal;
		$vetor["recordsFiltered"] = $recordsFiltered;
		foreach($processo as $u){
			$aux = array();
			

			$aux[] = $u->numeroprocesso;
			$aux[] = $u->dt_processo;
			$aux[] = $u->nomeprocesso;
			
			
			if($u->usuario_id != NULL){ 
				$red = new Usuario();
				$aux[] = $red->nomeUsuario($u->usuario_id);
			}else{
				$aux[] = null;
			}
			
			//$aux[] = $u->usuario_id;
			
			$info = '';
			
			
			if($u->usuario_id_redist != NULL){ 
				$red = new Usuario();
				$info = '<img style="padding-right:5px;" src="'.base_url('includes/images/adv.png').'" title="'.$red->nomeUsuario($u->usuario_id_redist).'" >';
			}
			$assistente = '';
			
			if($u->usuario_id_assis != NULL){ 
				$red = new Usuario();
				$info .= '<img style="padding-right:5px;" src="'.base_url('includes/images/ass.png').'" title="'.$red->nomeUsuario($u->usuario_id_assis).'">';
			}else{
				$assistente = '<a style="padding-left:5px;" data-toggle="modal"  data-target="#addassis" href="'.base_url("index.php/processos/assistente/$u->id").'" class="btn btn-primary btn-xs"><span class="glyphicon glyphicon-hand-right"></span> Assistente</a>';
			}
			
			if($u->status == '0'){ 
				$info .= '<img src="'.base_url('includes/images/arquivado.png').'" title="PROCESSO ARQUIVADO">';
			}
			
			if($u->mov == 'S'){ 
				$info .= '<img src="'.base_url('includes/images/saida1.png').'" title="PROCESSO FORA PROJU">';
			}
			
			$aux[] = $info;	
                                 
            		
			$aux[] = '<a style="padding: 1px 1px 1px 1px;" href="'.base_url("index.php/processos/info/$u->id").'" class="btn btn-success btn-xs"><span class="glyphicon glyphicon-plus"></span>Detalhes</a> '.$assistente.' <a style="padding: 1px 1px 1px 1px;" target=_blank href="'.base_url("index.php/processos/acompanhamento/$u->id").'" class="btn btn-info btn-xs"><span class="glyphicon glyphicon-print"></span> Acomp</a>';
			
			$aux[] = $u->observacao;
			
			array_push($dados,$aux);
		}
		$vetor["data"] = $dados;
		
		
		echo json_encode($vetor);
    }
	public function consultaProcessosGraficoUsuariosRedist($id){
		$usuarios = array();
		$adm = array();
		$jud = array();
		$exec = array();
	
		//11-12-2014 Comentado e substituido pelo codigo abaixo, em alguns momentos estava apresentando lentidao na consulta
		/* $result = $this->db->query("
		SELECT nome_completo, (
		SELECT COUNT(*)
		FROM processos
		WHERE processos.tipoprocesso_id = '1' AND processos.usuario_id_redist = usuarios.id AND processos.status = '1' AND date(processos.dt_cadastro) >= '2014-11-17'
		) AS adm,
		(
		SELECT COUNT(*)
		FROM processos
		WHERE processos.tipoprocesso_id = '2' AND processos.usuario_id_redist = usuarios.id AND processos.status = '1' AND date(processos.dt_cadastro) >= '2014-11-17'
		) AS jud,
		(
		SELECT COUNT(*)
		FROM processos
		WHERE processos.tipoprocesso_id = '3' AND processos.usuario_id_redist = usuarios.id AND processos.status = '1' AND date(processos.dt_cadastro) >= '2014-11-17'
		) AS exec
		FROM processos
		LEFT JOIN usuarios ON usuarios.id = processos.usuario_id_redist
		WHERE processos.usuario_id_redist = usuarios.id 
		AND usuarios.status='1'
		GROUP BY usuarios.id
		ORDER BY nome_completo ASC
		");	 */	
		
		$result = $this->db->query("
		SELECT nome_completo, (
		SELECT COUNT(*)
		FROM processos
		WHERE processos.tipoprocesso_id = '1' AND processos.usuario_id_redist = usuarios.id AND processos.status = '1' AND date(processos.dt_cadastro) >= '2014-11-17'
		) AS adm,
		(
		SELECT COUNT(*)
		FROM processos
		WHERE processos.tipoprocesso_id = '2' AND processos.usuario_id_redist = usuarios.id AND processos.status = '1' AND date(processos.dt_cadastro) >= '2014-11-17'
		) AS jud,
		(
		SELECT COUNT(*)
		FROM processos
		WHERE processos.tipoprocesso_id = '3' AND processos.usuario_id_redist = usuarios.id AND processos.status = '1' AND date(processos.dt_cadastro) >= '2014-11-17'
		) AS exec
		FROM usuarios
		WHERE usuarios.status='1' AND usuarios.permissao_id = '3'
		HAVING adm > 0 or jud > 0 or exec > 0
		ORDER BY nome_completo ASC
		");
		
		$info = array();
		$this->_process_query($result);

		foreach($this as $x){
			array_push($usuarios,$x->nome_completo);
			array_push($adm, (int)$x->adm);
			array_push($jud, (int)$x->jud);
			array_push($exec,(int)$x->exec);
		}
		if($id == '1'){
			return $adm;
		}elseif($id == '2'){
			return $jud;
		}elseif($id == '3'){
			return $exec;
		}elseif($id == '999'){
			return $usuarios;
		}
    }
	public function consultaProcessosGraficoUsuariosRedistAntigos($id){
		$usuarios = array();
		$adm = array();
		$jud = array();
		$exec = array();
	
		//11-12-2014 Comentado e substituido pelo codigo abaixo, em alguns momentos estava apresentando lentidao na consulta
		/* $result = $this->db->query("
		SELECT nome_completo, (
		SELECT COUNT(*)
		FROM processos
		WHERE processos.tipoprocesso_id = '1' AND processos.usuario_id_redist = usuarios.id AND processos.status = '1' AND date(processos.dt_cadastro) < '2014-11-17'
		) AS adm,
		(
		SELECT COUNT(*)
		FROM processos
		WHERE processos.tipoprocesso_id = '2' AND processos.usuario_id_redist = usuarios.id AND processos.status = '1' AND date(processos.dt_cadastro) < '2014-11-17'
		) AS jud,
		(
		SELECT COUNT(*)
		FROM processos
		WHERE processos.tipoprocesso_id = '3' AND processos.usuario_id_redist = usuarios.id AND processos.status = '1' AND date(processos.dt_cadastro) < '2014-11-17'
		) AS exec
		FROM processos
		LEFT JOIN usuarios ON usuarios.id = processos.usuario_id_redist
		WHERE processos.usuario_id_redist = usuarios.id 
		AND usuarios.status='1'
		GROUP BY usuarios.id
		ORDER BY nome_completo ASC
		"); */
		
		$result = $this->db->query("
		SELECT nome_completo, (
		SELECT COUNT(*)
		FROM processos
		WHERE processos.tipoprocesso_id = '1' AND processos.usuario_id_redist = usuarios.id AND processos.status = '1' AND date(processos.dt_cadastro) < '2014-11-17'
		) AS adm,
		(
		SELECT COUNT(*)
		FROM processos
		WHERE processos.tipoprocesso_id = '2' AND processos.usuario_id_redist = usuarios.id AND processos.status = '1' AND date(processos.dt_cadastro) < '2014-11-17'
		) AS jud,
		(
		SELECT COUNT(*)
		FROM processos
		WHERE processos.tipoprocesso_id = '3' AND processos.usuario_id_redist = usuarios.id AND processos.status = '1' AND date(processos.dt_cadastro) < '2014-11-17'
		) AS exec
		FROM usuarios
		WHERE usuarios.status='1' AND usuarios.permissao_id = '3'
		HAVING adm > 0 or jud > 0 or exec > 0
		ORDER BY nome_completo ASC
		");
		
		$info = array();
		$this->_process_query($result);

		foreach($this as $x){
			array_push($usuarios,$x->nome_completo);
			array_push($adm, (int)$x->adm);
			array_push($jud, (int)$x->jud);
			array_push($exec,(int)$x->exec);
		}
		if($id == '1'){
			return $adm;
		}elseif($id == '2'){
			return $jud;
		}elseif($id == '3'){
			return $exec;
		}elseif($id == '999'){
			return $usuarios;
		}
    }
	public function consultaProcessosGraficoUsuarios($id){
		$usuarios = array();
		$adm = array();
		$jud = array();
		$exec = array();
	
		//11-12-2014 Comentado e substituido pelo codigo abaixo, em alguns momentos estava apresentando lentidao na consulta
		/* $result = $this->db->query("
		SELECT nome_completo, (
		SELECT COUNT(*)
		FROM processos
		WHERE processos.tipoprocesso_id = '1' AND processos.usuario_id = usuarios.id AND processos.status = '1' AND date(processos.dt_cadastro) >= '2014-11-17'
		) AS adm,
		(
		SELECT COUNT(*)
		FROM processos
		WHERE processos.tipoprocesso_id = '2' AND processos.usuario_id = usuarios.id AND processos.status = '1' AND date(processos.dt_cadastro) >= '2014-11-17'
		) AS jud,
		(
		SELECT COUNT(*)
		FROM processos
		WHERE processos.tipoprocesso_id = '3' AND processos.usuario_id = usuarios.id AND processos.status = '1' AND date(processos.dt_cadastro) >= '2014-11-17'
		) AS exec
		FROM processos
		LEFT JOIN usuarios ON usuarios.id = processos.usuario_id
		WHERE processos.usuario_id = usuarios.id 
		AND usuarios.status='1'
		GROUP BY usuarios.id
		ORDER BY nome_completo ASC
		"); */
		
		$result = $this->db->query("
		SELECT nome_completo, (
		SELECT COUNT(*)
		FROM processos
		WHERE processos.tipoprocesso_id = '1' AND processos.usuario_id = usuarios.id AND processos.status = '1' AND date(processos.dt_cadastro) >= '2014-11-17'
		) AS adm,
		(
		SELECT COUNT(*)
		FROM processos
		WHERE processos.tipoprocesso_id = '2' AND processos.usuario_id = usuarios.id AND processos.status = '1' AND date(processos.dt_cadastro) >= '2014-11-17'
		) AS jud,
		(
		SELECT COUNT(*)
		FROM processos
		WHERE processos.tipoprocesso_id = '3' AND processos.usuario_id = usuarios.id AND processos.status = '1' AND date(processos.dt_cadastro) >= '2014-11-17'
		) AS exec
		FROM usuarios
		WHERE usuarios.status='1' AND usuarios.permissao_id = '3'
		HAVING adm > 0 or jud > 0 or exec > 0
		ORDER BY nome_completo ASC
		");
		
		$info = array();
		$this->_process_query($result);

		foreach($this as $x){
			array_push($usuarios,$x->nome_completo);
			array_push($adm, (int)$x->adm);
			array_push($jud, (int)$x->jud);
			array_push($exec,(int)$x->exec);
		}
		if($id == '1'){
			return $adm;
		}elseif($id == '2'){
			return $jud;
		}elseif($id == '3'){
			return $exec;
		}elseif($id == '999'){
			return $usuarios;
		}
    }
	public function consultaProcessosGraficoUsuariosAntigos($id){
		$usuarios = array();
		$adm = array();
		$jud = array();
		$exec = array();
	
		//11-12-2014 Comentado e substituido pelo codigo abaixo, em alguns momentos estava apresentando lentidao na consulta
		/* $result = $this->db->query("
		SELECT nome_completo, (
		SELECT COUNT(*)
		FROM processos
		WHERE processos.tipoprocesso_id = '1' AND processos.usuario_id = usuarios.id AND processos.status = '1' AND date(processos.dt_cadastro) < '2014-11-17'
		) AS adm,
		(
		SELECT COUNT(*)
		FROM processos
		WHERE processos.tipoprocesso_id = '2' AND processos.usuario_id = usuarios.id AND processos.status = '1' AND date(processos.dt_cadastro) < '2014-11-17'
		) AS jud,
		(
		SELECT COUNT(*)
		FROM processos
		WHERE processos.tipoprocesso_id = '3' AND processos.usuario_id = usuarios.id AND processos.status = '1' AND date(processos.dt_cadastro) < '2014-11-17'
		) AS exec
		FROM processos
		LEFT JOIN usuarios ON usuarios.id = processos.usuario_id
		WHERE processos.usuario_id = usuarios.id 
		AND usuarios.status='1'
		GROUP BY usuarios.id
		ORDER BY nome_completo ASC
		"); */
		
		$result = $this->db->query("
		SELECT nome_completo, (
		SELECT COUNT(*)
		FROM processos
		WHERE processos.tipoprocesso_id = '1' AND processos.usuario_id = usuarios.id AND processos.status = '1' AND date(processos.dt_cadastro) < '2014-11-17'
		) AS adm,
		(
		SELECT COUNT(*)
		FROM processos
		WHERE processos.tipoprocesso_id = '2' AND processos.usuario_id = usuarios.id AND processos.status = '1' AND date(processos.dt_cadastro) < '2014-11-17'
		) AS jud,
		(
		SELECT COUNT(*)
		FROM processos
		WHERE processos.tipoprocesso_id = '3' AND processos.usuario_id = usuarios.id AND processos.status = '1' AND date(processos.dt_cadastro) < '2014-11-17'
		) AS exec
		FROM usuarios
		WHERE usuarios.status='1' AND usuarios.permissao_id = '3'
		HAVING adm > 0 or jud > 0 or exec > 0
		ORDER BY nome_completo ASC
		");
		
		$info = array();
		$this->_process_query($result);

		foreach($this as $x){
			array_push($usuarios,$x->nome_completo);
			array_push($adm, (int)$x->adm);
			array_push($jud, (int)$x->jud);
			array_push($exec,(int)$x->exec);
		}
		if($id == '1'){
			return $adm;
		}elseif($id == '2'){
			return $jud;
		}elseif($id == '3'){
			return $exec;
		}elseif($id == '999'){
			return $usuarios;
		}
    }
	public function consultaProcessosGrafico(){
		$tipoprocesso = new TipoProcesso();
		$tipoprocesso->select("id")->get();
		$dados = array();
		foreach($tipoprocesso as $x){
			$result = $this->db->query("
			SELECT nomeprocesso,COUNT(*) AS quantidade
			FROM processos
			LEFT JOIN tipoprocessos ON tipoprocessos.id = processos.tipoprocesso_id
			WHERE processos.tipoprocesso_id ='$x->id' 	
			and processos.`status` = '1'
			");
			
			
			$info = array();
			$this->_process_query($result);

			foreach($this as $x){
				$info[] = $x->nomeprocesso ;
				$info[] =  (int)$x->quantidade;
				if($x->quantidade != '0')
					array_push($dados,$info);
			}

		}
		
		return $dados;
    }
	public function consultaProcessosGraficoAntigos(){
		$tipoprocesso = new TipoProcesso();
		$tipoprocesso->select("id")->get();
		$dados = array();
		foreach($tipoprocesso as $x){
			$result = $this->db->query("
			SELECT nomeprocesso,COUNT(*) AS quantidade
			FROM processos
			LEFT JOIN tipoprocessos ON tipoprocessos.id = processos.tipoprocesso_id
			WHERE processos.tipoprocesso_id ='$x->id' 	
			and processos.`status` = '1'
			");
			
			
			$info = array();
			$this->_process_query($result);

			foreach($this as $x){
				$info[] = $x->nomeprocesso ;
				$info[] =  (int)$x->quantidade;
				if($x->quantidade != '0')
					array_push($dados,$info);
			}

		}
		
		return $dados;
    }
	public function graficoMes($id){

		$result = $this->db->query("
		SELECT EXTRACT(MONTH
		FROM dt_processo) AS 'mes', COUNT(*) AS 'total'
		FROM processos
		WHERE EXTRACT(YEAR
		FROM dt_processo) = ".date('Y')." AND processos.tipoprocesso_id = '$id' AND processos.status = '1'
		GROUP BY EXTRACT(MONTH
		FROM dt_processo)
		");
		
		
		$processo = new Processo();
		$processo->_process_query($result);
		
		return $processo;

    }
	public function acompanhamento($id)    {

		$result = $this->db->query("
		SELECT processos.numeroprocesso, processos.dt_processo,tipoprocessos.nomeprocesso, usuarios.nome_completo, assuntos.descricao
		FROM processos
		LEFT JOIN tipoprocessos ON tipoprocessos.id = processos.tipoprocesso_id
		LEFT JOIN usuarios ON usuarios.id = processos.usuario_id
		LEFT JOIN assuntos ON assuntos.id = processos.assunto_id
		where processos.id = '$id'
		ORDER BY dt_processo DESC
		");
		
		
		$processo = new Processo();
		$processo->_process_query($result);
		
		return $processo;

    }
	public function voltaProcessoDono($id, $dt_inicio, $dt_fim)    {

		$result = $this->db->query("
		SELECT processos.id
		FROM processos
		WHERE usuario_id='".$id."'
		AND usuario_id_redist IS NOT NULL 
		AND '$dt_fim' < CURRENT_TIMESTAMP 
		AND (processos.dt_cadastro BETWEEN '".$dt_inicio."' AND '".$dt_fim."')
		");
				
		$info = array();
		$this->_process_query($result);

		foreach($this as $x){
			$info[] = $x->id ;
		}
		return $info;
    }
	public function consultaRedistribuicao($id, $inicio, $fim) {

		$result = $this->db->query("
			SELECT DATE_FORMAT(processos.dt_processo,' %d/%m/%Y') AS dt_processo, numeroprocesso, nomeprocesso,usuario_id_redist, nome_completo, processos.id
			FROM processos
			LEFT JOIN tipoprocessos ON tipoprocessos.id = processos.tipoprocesso_id
			LEFT JOIN usuarios ON usuarios.id = processos.usuario_id_redist
			WHERE usuario_id = '$id' AND usuario_id_redist IS NOT NULL
			AND dt_processo between '$inicio' and '$fim'
			ORDER BY usuario_id_redist ASC, tipoprocesso_id ASC
		");
				
		$p = new Processo();
		$p->_process_query($result);

		return $p;
    }
	public function joao() {

		$result = $this->db->query("
		SELECT *
		FROM processos
		WHERE numeroprocesso IN ('12986-10.2012.8.16.0045','13089-17.2012.8.16.0045','6689-89.2009.8.16.0045','6789-44.2009.8.16.0045','516-62.2014.8.16.0045','0800-43.2014.8.16.0045','12029-09.2012.8.16.0045','12410-17.2012.8.16.0045','12106-52.2011.8.16.0045','13096-43.2011.8.16.0045','6822-34.2009.8.16.0045','9739-84.2013.8.16.0045','5490-61.2011.8.16.0045','10805-65.2014.8.16.0045','13063-53.2011.8.16.0045','12727-49.2011.8.16.0045','7975-97.2012.8.16.0045','12621-87.2011.8.16.0045','9509-42.2013.8.16.0045','3304-60.2014.8.16.0045','3965-39.2014.8.16.0045','1573-12.2014.8.16.0180','38-2007','11991-94.2012.8.16.0045','12426-68.2012.8.16.0045','12900-39.2012.8.16.0045','12527-71.2013.8.16.0045','3953-25.2014.8.16.0045','4178-45.2014.8.16.0045','10809-05.2014.8.16.0045','13087-47.2012.8.16.0045','6688-07.2009.8.16.0045','13040-10.2011.8.16.0045','608-2006','3963-69.2014.8.16.0045','4189-74.2014.8.16.0045')
		");
				
		$p = new Processo();
		$p->_process_query($result);

		return $p;
    }
	public function consultaProcessosGraficoAnual($inicio, $fim){
		$tipoprocesso = new TipoProcesso();
		$tipoprocesso->select("id")->get();
		$dados = array();
		foreach($tipoprocesso as $x){
			$result = $this->db->query("
			SELECT nomeprocesso,COUNT(*) AS quantidade
			FROM processos
			LEFT JOIN tipoprocessos ON tipoprocessos.id = processos.tipoprocesso_id
			WHERE processos.tipoprocesso_id ='$x->id' 	
			and processos.`status` = '1'  AND (processos.dt_cadastro BETWEEN '$inicio' AND '$fim')
			");
			
			
			$info = array();
			$this->_process_query($result);

			foreach($this as $x){
				$info[] = $x->nomeprocesso ;
				$info[] =  (int)$x->quantidade;
				if($x->quantidade != '0')
					array_push($dados,$info);
			}

		}
		
		return $dados;
    }
	public function consultaProcessosGraficoUsuariosAnual($id, $inicio, $fim){
		$usuarios = array();
		$adm = array();
		$jud = array();
		$exec = array();
	
		//11-12-2014 Comentado e substituido pelo codigo abaixo, em alguns momentos estava apresentando lentidao na consulta
		/* $result = $this->db->query("
		SELECT nome_completo, (
		SELECT COUNT(*)
		FROM processos
		WHERE processos.tipoprocesso_id = '1' AND processos.usuario_id = usuarios.id AND processos.status = '1' AND (processos.dt_cadastro BETWEEN '$inicio' AND '$fim')
		) AS adm,
		(
		SELECT COUNT(*)
		FROM processos
		WHERE processos.tipoprocesso_id = '2' AND processos.usuario_id = usuarios.id AND processos.status = '1' AND (processos.dt_cadastro BETWEEN '$inicio' AND '$fim')
		) AS jud,
		(
		SELECT COUNT(*)
		FROM processos
		WHERE processos.tipoprocesso_id = '3' AND processos.usuario_id = usuarios.id AND processos.status = '1' AND (processos.dt_cadastro BETWEEN '$inicio' AND '$fim')
		) AS exec
		FROM processos
		LEFT JOIN usuarios ON usuarios.id = processos.usuario_id
		WHERE processos.usuario_id = usuarios.id 
		AND usuarios.status='1'
		GROUP BY usuarios.id
		ORDER BY nome_completo ASC
		"); */
		
		$result = $this->db->query("
		SELECT nome_completo, (
		SELECT COUNT(*)
		FROM processos
		WHERE processos.tipoprocesso_id = '1' AND processos.usuario_id = usuarios.id AND processos.status = '1' AND (processos.dt_cadastro BETWEEN '$inicio' AND '$fim')
		) AS adm,
		(
		SELECT COUNT(*)
		FROM processos
		WHERE processos.tipoprocesso_id = '2' AND processos.usuario_id = usuarios.id AND processos.status = '1' AND (processos.dt_cadastro BETWEEN '$inicio' AND '$fim')
		) AS jud,
		(
		SELECT COUNT(*)
		FROM processos
		WHERE processos.tipoprocesso_id = '3' AND processos.usuario_id = usuarios.id AND processos.status = '1' AND (processos.dt_cadastro BETWEEN '$inicio' AND '$fim')
		) AS exec
		FROM usuarios
		WHERE usuarios.status='1' AND usuarios.permissao_id = '3'
		HAVING adm > 0 or jud > 0 or exec > 0
		ORDER BY nome_completo ASC
		");
		
		$info = array();
		$this->_process_query($result);

		foreach($this as $x){
			array_push($usuarios,$x->nome_completo);
			array_push($adm, (int)$x->adm);
			array_push($jud, (int)$x->jud);
			array_push($exec,(int)$x->exec);
		}
		if($id == '1'){
			return $adm;
		}elseif($id == '2'){
			return $jud;
		}elseif($id == '3'){
			return $exec;
		}elseif($id == '999'){
			return $usuarios;
		}
    }
	
}

/* End of file processo.php */
/* Location: ./application/models/processo.php */
